function fv=stnd5(n,mu,sigma,w1,w2,a,b)
%******************************************************************
%** This is a supporting function for "sampling3.m"              **
%** Created by Min-Hua Huang, Dec 19, 2011                       **
%** n:sample size                                                **
%** mu:location parameter                                        **
%** sigma:scale parameter                                        **
%** w1:the weight for the random part, varying from 0 to 1       **
%** w2:the weight for non-collinearity, varying from 0 to 1      **
%** a:lower limit                                                **
%** b:upper limit                                                **
%** output:random variable of truncated normal                   **
%******************************************************************
format long; 
p=rand(n,1);
temp=p.*(normcdf(b,mu,sigma)-normcdf(a,mu,sigma))+normcdf(a,mu,sigma);
y=norminv(temp,mu,sigma);
total=stnd6(y,w1,w2);  
fv=total;
